<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link href="${contextPath}/resource/css/css.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css"
			href="${contextPath}/resource/css/default.css" />
		<link rel="stylesheet" type="text/css"
			href="${contextPath}/resource/tree/zTreeStyle/zTreeStyle.css" />
		<script type="text/javascript"
			src="${contextPath}/resource/tree/jquery-1.4.2.js">
			
</script>
		<script type="text/javascript"
			src="${contextPath}/resource/tree/jquery.ztree-2.6.js">
</script>
		<script type="text/javascript"
			src="${contextPath}/resource/js/systemUtil.js">
</script>
		<!-- 单选按钮 -->
		<script type="text/javascript">
          function submitFrom(fm){
	
		if(document.getElementById("driverInfo.azfs").value ==""){
			alert("安装方式不能为空!");
			return;
		}
		if(document.getElementById("driverInfo.system").value ==""){
			alert(" 操作系统不能为空!");
			return;
		}
		if(document.getElementById("driverInfo.version").value ==""){
			alert(" 版本号不能为空!");
			return;
		}
		
		fm.submit();
	}
	
	
	function getSelectMobile(brand)
    {
   
			var url ="${contextPath}/driver/driverInfoAction_getSelectMobile.do";
		
			$.post(url,{'brand': brand},function(data){
		  	  
		  	    var res = eval('('+data+')');
		  	    var length = 0;
				var dataPhone = res.result
				length= dataPhone.length;
				var str = "<div class=\"driver\">";
		    	str+="<div class=\"driver_model\"><input name=\"box\" type=\"checkbox\" value=\"\" id=\"checkedAll\" onclick='clickBox();'/></div>";
		    	str+="<div class=\"driver_model_text\">全选</div>";
		    	str+="</div>";
		    	for(i=0;i<length;i++)
		       	{
		           	var object = dataPhone[i];
					if(length%2==0)
					{
						if(i%2==0)
						{
							str+="<div class='driver'>";
							str+="<div class='driver_model'><input name='mobileIds' type='checkbox' value='"+object.id+"' id='box1'/></div>";
							str+="<div class='driver_model_text'>"+object.jx+"</div>";
						}
						else
						{
							str+="<div class='driver_model'><input name='mobileIds' type='checkbox' value='"+object.id+"' id='box1'/></div>";
							str+="<div class='driver_model_text'>"+object.jx+"</div>";
							str+="</div>";
						}
					}
					if(length%2==1)
					{
						if(i%2==0)
						{
							str+="<div class='driver'>";
							str+="<div class='driver_model'><input name='mobileIds' type='checkbox' value='"+object.id+"' id='box1'/></div>";
							str+="<div class='driver_model_text'>"+object.jx+"</div>";
						}
						if(i%2==1)
						{
							str+="<div class='driver_model'><input name='mobileIds' type='checkbox' value='"+object.id+"' id='box1'/></div>";
							str+="<div class='driver_model_text'>"+object.jx+"</div>";
							str+="</div>";
						}
						if(i==(length-1))
						{
							str+="</div>";
						}
					}
		        }
		    	$("#driverOne").html("");
		    	$("#driverOne").html(str);
			});

          }

function clickBox()
{
	 if ($("#checkedAll").attr("checked") == true) 
		{ // 全选    
		   $(":checkbox[name='mobileIds']").each(function() {    
		  	 $(this).attr("checked", true);    
		  });    
		} 
		else 
		{ // 取消全选    
		   $(":checkbox[name='mobileIds']").each(function(){    
		   $(this).attr("checked", false);    
		  }); 
	}    
}
</script>
	</head>
	<body>
		<s:form action="driverInfoAction_save.do" namespace="/driver" method="post"  enctype="multipart/form-data">
			<table class="menu_table">
				<tr>
					<th>
						<a href="driverInfoAction_list.do">手机驱动信息管理</a>&gt;&gt;新增手机驱动信息
					</th>
				</tr>
			</table>
			<div class="listtable">
				<div class="secondDiv">
					<table class="form_table">
						<tr>
							<th width="20%">
								上传驱动文件
							</th>
							<td width="15%">
									<s:file id="driverFile" name ="driverFile" ></s:file>
								<span class="txtblue" id="resultadminUser">*</span>
							</td>
						</tr>
						 <tr>
							<th width="20%">
							   安装方式
							</th>
							<td width="35%">
								<s:select list="#{'0':'静默安装','1':'适时安装'}" name="driverInfo.azfs"></s:select>
							</td>
						</tr>
						<tr>
							<th>
								操作系统
							</th>
							<td>
								<s:select list="#{'XP系统':'XP系统','WINDOW7系统':'WINDOW7系统'}" name="driverInfo.system"></s:select>
							</td>
							
						</tr>
						<tr>
							<th>
								版本号
							</th>
							<td>
								<s:textfield  name="driverInfo.version" id="driverInfo.version" maxlength="10" size="10"></s:textfield>
								<span class="txtblue" id="resulpassword">*</span>
							</td>
							
						</tr>
						<tr>
							<th>
								适配驱动机型
							</th>
							<td>
								<s:select list="phoneBrand" name="brand" onchange="getSelectMobile(this.value)"></s:select>
								
								<div style="height:5px"></div>
				                <div id="driverOne" style="display: block;">
				                    
				                </div>  
							</td>
						</tr>
						
						
					</table>
					
		<table width="80%" border="0" align="center" cellpadding="3" cellspacing="1">
			<s:token></s:token>
		    <tr>
		      <td align="center"  >
		      <div align="center">
		      	<input type="button" value="" class="apply_style" align="middle" onclick="submitFrom(this.form);"/>
		        <input type="button" onclick="javascript:location='driverInfoAction_list.do'" class="back_style"  />
		        <input type="reset" id="重置 " class="reset_style" value=""/>
		        </div>
		        </td>
		    </tr>
		</table>
				</div>
			</div>
		</s:form>
	</body>
</html>
